package com.sqx.modules.orders.service;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sqx.common.utils.PageUtils;
import com.sqx.common.utils.Result;
import com.sqx.modules.orders.entity.Orders;
import com.sqx.modules.utils.excel.ExcelData;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;


public interface OrdersService extends IService<Orders> {

    int selectMyOrdersCount(Long userId, String time);

    int selectTakeOrdersCount(Long userId, String time);


    /**
     * 生成订单
     *
     * @param userId
     * @param id
     * @param type
     * @param orderNumber
     * @param remarks
     * @param couponId
     * @param khname
     * @param khphone
     * @return
     */
    Result generateOrder(Long userId, Long id, Long type, Long orderNumber, String remarks, Long addressId, String startTime, Long serviceTimeId, Long couponId, String khname, String khphone);

    Result updateOrdersAddress(Long ordersId, Long addressId);

    /**
     * 查看我的订单
     *
     * @param userId
     * @return
     */
    Result selectMyOrder(Long userId, IPage iPage, String status, Long orderTakingUserId);

    /**
     * 生成充值订单
     *
     * @param userId
     * @param money
     * @return
     */
    Result investOrder(Long userId, Double money, Integer classify);

    /**
     * 取消订单
     *
     * @param id
     * @param status
     * @return
     */
    Result cancelOrder(Long id, String status, String code, String startServiceImg, String endServiceImg, BigDecimal money,
                       String startServiceLongitude, String startServiceLatitude,
                       String endServiceLongitude, String endServiceLatitude,Integer type);

    /**
     * 删除订单
     *
     * @param id
     * @param
     * @return
     */
    Result deleteOrder(Long id);

    /**
     * \
     * 查询订单详情
     *
     * @param id
     * @return
     */
    Result queryOrders(Long id);

    /**
     * 查看所有订单
     */
    Result queryOrdersAll(Long page, Long limit, Long type, String userName,String ordersUserName, Long status, Long userId, String ordersNo, String startTime, String endTIme, Long orderTakingUserId,String companyName);

    ExcelData ordersListExcel(Long type, String name, Long status, Long userId, String ordersNo, String startTime, String endTIme);

    Result selectMyTakeOrders(Integer page, Integer limit, Long userId, Integer status, Long staffUserId, String name, String phone, String startTime, String staffUserName, String ordersNo);

    Result selectStaffUserOrders(Integer page, Integer limit, Long userId, Integer status, String name, String phone, String startTime, String ordersNo, Long orderTakingUserId);

    Result payMoney(Long ordersId);

    PageUtils incomeAnalysisOrders(Integer page, Integer limit, String time, Integer flag);

    Integer getOrdersRemind(Long userId);

    int updateOrdersIsRemind(Long userId);

    Result selectTeamOrdersList(Integer page, Integer limit, Long userId, Integer type, Integer status);

    Result selectTeamUserList(Integer page, Integer limit, String invitationCode, Integer type, Long userId);


    Double selectOrdersMoneyCountByUserId(Long userId, Integer type);

    Integer selectUserCountByInvitationCode(String invitationCode, Integer type);

    Result selectStaffUserOrdersByTime(Integer page, Integer limit, Long companyId, String startTime, String endTime, String phone, String userName);

    Result selectStaffUserHelpTakesByTime(Integer page, Integer limit, Long companyId, String startTime, String endTime, String phone, String userName);

    Integer selectRankingByUserId(Long userId, Long companyId);

    Integer selectOrdersCountByCompany(Long userId);

    BigDecimal selectOrdersMoneyByCompany(Long userId);

    Map<String, Object> selectOrdersCountByStaffUser(Long userId, Long companyId,  String taskTime, String time, Integer flag);

    Map<String, Object> selectOrdersMoneyByStaffUser(Long userId, Long companyId,String taskTime, String time, Integer flag);

    Map<String, Object> selectOrdersRefundCountByStaffUser(Long userId, Long companyId,String taskTime, String time, Integer flag);

    Map<String, Object> selectOrdersRefundMoneyByStaffUser(Long userId, Long companyId,String taskTime, String time, Integer flag);

    Integer selectOrdersCountByStatusAndTime(String time, Integer flag, Integer state);

    BigDecimal sumOrdersByCreateTime(String time, Integer flag, Integer payWay);

    IPage<HashMap<String, Object>> getAgentProfit(Integer page, Integer limit);

    IPage<HashMap<String, Object>> getStaffInfo(Integer page, Integer limit, Long companyId,String time, Integer flag);

    IPage<HashMap<String, Object>> getShopInfo(Integer page, Integer limit,String time,Integer flag);

    HashMap<String, Object> selectStaffStatistics(Long userId, String startTime, String endTime);

    IPage<Orders> selectNowDayOrders(Integer page, Integer limit, Long userId);

    /**
     * @param userId
     * @param ordersId  订单id
     * @param money     支付价格
     * @param payType   支付方式 0余额  1app微信 2微信公众号 3微信小程序 4 app支付宝 5支付宝H5
     * @param orderType 订单类型 1万能任务 2接单任务
     * @return
     */
    Result repairFee(Long userId, Long ordersId, BigDecimal money, Integer payType, Integer orderType, HttpServletRequest request) throws Exception;

    Result payBack(Long orderId, Integer orderType, Integer payType, BigDecimal money,String payOrdersNo);

    Result selectRefundMoney(Long orderId,Integer orderType);

    Result refundMoney(Long orderId,BigDecimal money,Integer orderType);

    Result refundOrders(Long orderId,Integer orderType);

    IPage<HashMap<String,Object>> getStaffOrderList(Integer page, Integer limit, Long userId);

    IPage<HashMap<String,Object>> getStaffUserOrder(Integer page, Integer limit, Long companyId);

    HashMap<String,Object> getUserStatistics(String time, Integer flag);

    HashMap<String,Object> getOrderStatusCount(Long userId);

    /**
     * 下单播报
     * @return
     */
    Result orderBroadcast();
}
